//
//  NewHomeNewsView.m
//  NewPro
//
//  Created by RYX on 2019/4/18.
//  Copyright © 2019 何荧红. All rights reserved.
//

#import "NewHomeNewsView.h"
#import "SDCycleScrollView.h"

@interface NewHomeNewsView ()

@property (nonatomic,strong) SDCycleScrollView *sdView;

@end

@implementation NewHomeNewsView

- (SDCycleScrollView *)sdView{
    
    if (!_sdView) {
        
        _sdView = [SDCycleScrollView cycleScrollViewWithFrame:CGRectZero delegate:nil placeholderImage:nil];
        _sdView.scrollDirection = UICollectionViewScrollDirectionVertical;
        _sdView.onlyDisplayText = YES;
        _sdView.autoScrollTimeInterval = 2.0f;
        _sdView.titleLabelTextFont = [UIFont fontWithName:@"PingFang-SC-Medium" size: 12];
        _sdView.titleLabelTextColor = UIColor.blackColor;
        _sdView.titleLabelBackgroundColor = UIColor.whiteColor;
        _sdView.userInteractionEnabled = NO;
    
    }
    return _sdView;
}

- (instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        
        self.backgroundColor = UIColor.whiteColor;
        [self setUI];
    }
    return self;
}

- (void)setUI{
    
    UILabel *la = [[UILabel alloc] init];
    la.font = [UIFont systemFontOfSize:14];
    la.text = @"头条播报";
    la.textColor = UIColor.redColor;
    [self addSubview:la];
    
    UIImageView *im = [[UIImageView alloc] init];
    im.image = [UIImage imageNamed:@"头条播报"];
    [self addSubview:im];
    
    [self addSubview:self.sdView];
    
    [la mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(self).offset(14);
        make.top.bottom.equalTo(self);
    }];
    
    [im mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(la.mas_right).offset(5);
        make.centerY.equalTo(self);
        make.height.width.mas_equalTo(10);
    }];
    
    [self.sdView mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.equalTo(im.mas_right).offset(10);
        make.right.equalTo(self).offset(-14);
        make.top.bottom.equalTo(self);
    }];
}

- (void)setListArr:(NSArray *)listArr{
    
    self.sdView.titlesGroup = listArr;
}
@end
